package com.zb.yaml;

import org.springframework.beans.factory.annotation.Value;

import java.util.ArrayList;
import java.util.List;

/**
 * 跨域配置工具类
 * @Author WEN
 * @Date 2023/11/16 0016
 **/
public class CorsUtil {
    /**
     * TODO 待完成类，对象未初始化到spring容器中，加载的时机不对，待后续完善
     */
    private static CorsUtil corsUtil;

    @Value("${cors.origin}")
    private String origin;

    public void init() {
        corsUtil = this;
        corsUtil.origin = this.origin;
    }

    public static List<String> getOrigin() {
        List<String> originList = new ArrayList<>();
//        String o = corsUtil.origin;
//        if (o.contains("-1")) {
            originList.add("*");
//        } else {
//            originList.addAll(Arrays.asList(o.split(",")));
//        }
        return originList;
    }


}
